package com.chucang.shucang.common.base.query;

import com.chucang.shucang.common.base.constant.CommonConstant;
import lombok.Setter;
import org.hibernate.validator.constraints.Range;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2022/9/12 17:34
 * @description 统一条件分页查询类
 */
@Setter
public class Query {

    @Range(min = 1, max = 100, message = "最多分100页")
    Integer page;

    @Range(min = 1, max = 100, message = "每页最多返回100条")
    Integer limit;

    String orderField;

    String order;

    public String getOrderField() {
        return orderField;
    }

    public String getOrder() {
        return this.order == null ? CommonConstant.ASC : order;
    }

    public Integer getPage() {
        return this.page == null ? 1 : page;
    }

    public Integer getLimit() {
        return this.limit == null ? 10 : limit;
    }

}